package com.oneproject.infrastructure.data.unitofwork;

import java.lang.reflect.Field;
import java.util.Map;

/**
 *
 *
 * @author 马文韬
 * @Date: 2018/9/12
 * @Version 1.0
 */
public final class EntityBuilder {

    public static String PRIMARY_KEY_KEY = "PK";

    private final ModelBuilder parentBuilder;

    private final Class<?> entityClazz;

    public EntityBuilder(ModelBuilder parentBuilder, Class<?> entityClazz) {
        this.parentBuilder = parentBuilder;
        this.entityClazz = entityClazz;
    }

    public EntityBuilder hasPrimaryKey(Field field) {
        Map<String, Object> entityMap = parentBuilder.modelMap.get(entityClazz);
        entityMap.put(PRIMARY_KEY_KEY, field);
        return this;
    }
}
